<?php
namespace app\common;

/**
 * Description of Dictionary
 *
 * @author wang
 */
class Dictionary
{
    /**
     * ------------------------------------------
     * 把返回的数据集转换成Tree
     * @param array $list 要转换的数据集
     * @param string $pk 主键
     * @param string $pid parent标记字段
     * @param string $child
     * @param int $root
     * @return array
     * ------------------------------------------
     */
    public static function getPersonnel($data)
    {
        $sql = "SELECT value FROM t_sys_dictionary WHERE value='".$data['type']."' AND del_flag=0";
        $result = \Yii::$app->db->createCommand($sql)->queryOne();
        return $result['value'];
    }
    public static function getQuestionType($data)
    {
        foreach ($data as $key =>& $value) {
            $sql = "SELECT name FROM t_sys_dictionary WHERE value='".$value['type']."' AND del_flag=0";
            $result = \Yii::$app->db->createCommand($sql)->queryOne();
            $value['type'] = $result['name'];
        }
        return $data;
    }
}
